package sample.plugin.language.lua.decision;

import static sample.plugin.language.lua.LuaToken.*;

import com.rapid.api.lang.engine.highlight.decision.DecisionResult;
import com.rapid.api.lang.engine.highlight.token.TokenModel;

import sample.plugin.language.base.AbstractDecision;
import sample.plugin.language.lua.LuaState;

public class LuaBlockDecision extends AbstractDecision<LuaState> {
    @Override
    public Iterable<DecisionResult> decide(TokenModel model, LuaState state) {
        switch (model.token) {
            case FOR:
            case FUNCTION:
            case IF:
            case WHILE: {
                DecisionResult result = new DecisionResult();
                result.kind = DecisionResult.ResultKind.BLOCK_HEAD;
                return single(result);
            }
            case ELSE:
            case ELSEIF: {
                DecisionResult result1 = new DecisionResult();
                result1.kind = DecisionResult.ResultKind.BLOCK_TAIL;
                DecisionResult result2 = new DecisionResult();
                result2.kind = DecisionResult.ResultKind.BLOCK_HEAD;
                return results(result1, result2);
            }
            case END: {
                DecisionResult result = new DecisionResult();
                result.kind = DecisionResult.ResultKind.BLOCK_TAIL;
                return single(result);
            }
        }
        return refuse();
    }
}
